import pickle
import pandas as pd

from sklearn.metrics import f1_score
# more imports


def load_model(model_path):
    with open(model_path, 'rb') as f:
        model = pickle.load(f)
    return model


def load_data(data_path):
    df = pd.read_csv(data_path)
    x = df.iloc[:, 1:-2]
    y = df.iloc[:, -1]
    return x, y


def predict(model, testX):
    return model.predict(testX)


def test_score(model, testX, testY):
    preY = predict(model, testX)
    pre_score = f1_score(preY, testY)
    f1 = pre_score
    return preY, f1


if __name__ == '__main__':
    model_path = 'model-lr.pkl'
    model = load_model(model_path)
    data_path = 'test.csv'
    testX, testY = load_data(data_path)
    _, score = test_score(model, testX, testY)
    print(score)
